<?php
include_once '../common.func.php';
$posts = getPosts();

$tags = array();

foreach ($posts as $post) {
    foreach ($post['tag'] as $tagName) {
        if (!isset($tags[$tagName])) {
            $tags[$tagName] = array('name' => $tagName, 'posts' => array());
        }
        array_push($tags[$tagName]['posts'], $post['url']);
    }
}
//var_dump($tags);
saveTags($tags);
